package com.bjpowernode.dao;

import com.bjpowernode.entity.Users;
import com.bjpowernode.util.JDBCUtil;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UserDao {
    private JDBCUtil util = new JDBCUtil();

    public int add(Users users) {

        String sql = "insert into users(userName,passWord,sex,email) values (?,?,?,?)";

        PreparedStatement ps = util.createStatement(sql);
        int result = 0;
        try{

            ps.setString(1, users.getUserName());
            ps.setString(2, users.getPassWord());
            ps.setString(3, users.getSex());
            ps.setString(4, users.getEmail());
            result = ps.executeUpdate();
        }catch (SQLException e){
            e.printStackTrace();
        }finally {
//            util.close();
        }
        return result;
    }
}
